I'm looking into doing a delta_sigma emulator. This is testing if the cat side works. Then i'll make an emulator for it.
In [1]:
from pearce.mocks import cat_dict
import numpy as np
from os import path
from astropy.io import fits
In [2]:
import matplotlib
#matplotlib.use('Agg')
from matplotlib import pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()
In [3]:
z_bins = np.array([0.15, 0.3, 0.45, 0.6, 0.75, 0.9])
zbin=1
In [4]:
zbc = (z_bins[1:]+z_bins[:-1])/2
print 1/(1+zbc)
In [5]:
a = 0.81120
z = 1.0/a - 1.0
Load up a snapshot at a redshift near the center of this bin.
In [6]:
print z
In [7]:
cosmo_params = {'simname':'chinchilla', 'Lbox':400.0, 'scale_factors':[a]}
cat = cat_dict[cosmo_params['simname']](**cosmo_params)#construct the specified catalog!
cat.load_catalog(a, particles=True, tol = 0.01, downsample_factor=1e-3)
In [8]:
cat.load_model(a, 'redMagic')
In [9]:
from astropy import cosmology
In [10]:
params = cat.model.param_dict.copy()
#params['mean_occupation_centrals_assembias_param1'] = 0.0
#params['mean_occupation_satellites_assembias_param1'] = 0.0
#my clustering redmagic best fit
params['logMmin'] = 12.386
params['sigma_logM'] = 0.4111
params['f_c'] = 0.292
params['alpha'] = 1.110
params['logM1'] = 13.777
params['logM0'] = 11.43433
print params
In [11]:
print cat
In [12]:
help(cat.calc_gt)
In [13]:
cat.populate(params)
In [14]:
nd_cat = cat.calc_analytic_nd(params)
print nd_cat
In [15]:
fname = '/u/ki/jderose/public_html/bcc/measurement/y3/3x2pt/buzzard/flock/buzzard-2/tpt_Y3_v0.fits'
hdulist = fits.open(fname)
In [16]:
nz_sources = hdulist[6]
sources_zbin = 1
N_z = np.array([row[2+sources_zbin] for row in nz_sources.data])
N_total = np.sum(N_z)#*0.01
N_z/=N_total # normalize
zbins = [row[0] for row in nz_sources.data]
zbins.append(nz_sources.data[-1][2])
In [17]:
sc_inv = cat.calc_sigma_crit_inv(zbins, N_z)
print sc_inv
In [18]:
zs = np.sum(zbins[:-1]*N_z)
In [19]:
zs
Out[19]:
In [20]:
sc_inv
Out[20]:
In [21]:
rp_bins = np.logspace(-1.1, 1.8, 20) #binning used in buzzard mocks
#rpoints = (rp_bins[1:]+rp_bins[:-1])/2
theta_bins = np.logspace(np.log10(2.5), np.log10(250), 21)/60
#theta_bins = cat._ang_from_rp(rp_bins)
#rp_bins = cat._rp_from_ang(theta_bins)
rpoints = np.sqrt(rp_bins[1:]*rp_bins[:-1])
tpoints = np.sqrt(theta_bins[1:]*theta_bins[:-1])#(theta_bins[1:]+theta_bins[:-1])/2
In [22]:
gt = cat.calc_gt(theta_bins, 1.0, n_cores = 2)
In [23]:
from scipy.interpolate import interp1d
from scipy.integrate import quad
import pyccl as ccl
In [24]:
tbins = (theta_bins[1:]+theta_bins[:-1])/2.0
plt.plot(tbins*60, gt)
plt.ylabel(r'$\gamma_t(\theta)$')
plt.xlabel(r'$\theta$ [Arcmin]')
plt.loglog()
Out[24]:
In [25]:
gt_data = hdulist[3].data
gt_rm, gt_bc = [],[]
for i, row in enumerate(gt_data):
if i == 20:
break
gt_rm.append(row[3])#gt_data[3,:20]
gt_bc.append(row[4])
In [26]:
print gt_bc
print tbins*60
In [27]:
gt_rm, gt
Out[27]:
In [29]:
plt.plot(gt_bc, gt_rm)
plt.plot(tbins*60, sc_inv*gt)#/cat.h)
plt.ylabel(r'$\gamma_t(\theta)$')
plt.xlabel(r'$\theta$ [Arcmin]')
plt.loglog()
Out[29]: